<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>

  <body>
    <div id="app">
      <my-com></my-com>
      <my-coms></my-coms>
    </div>

    <template id="com">
      <div>
        我是局部组件--{{ count }}
        <button @click="add">点我+</button>
      </div>
    </template>

    <template id="com2">
      <div>我是局部组件2--{{ count }}</div>
    </template>

    <script src="../vue.js"></script>
    <script>
      const Com = {
        template: "#com",
        data() {
          return {
            count: 100,
          };
        },
        methods: {
          add() {
            this.count += 1;
          },
        },
      };

      // 第二个组件
      const Com2 = {
        template: "#com2",
        data() {
          return {
            count: 100,
          };
        },
      };

      new Vue({
        el: "#app",
        // 注册组件
        // components: { 组件名称: 组件内容 }
        components: {
          "my-com": Com,
          "my-coms": Com2,
        },
      });
    </script>
  </body>
</html>
